package com.face.receive.jsu;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import com.face.operate.jsu.Prestore;

//获取该集合下的照片
@WebServlet("/GetPrestore")
public class GetPrestore extends HttpServlet {

	String url = "http://47.106.35.203:8080/prestore/";
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String phone_num = request.getParameter("username");
		Prestore pre = new Prestore();
		List<String> list = pre.selectByPhoneNum(phone_num);
		JSONArray json = new JSONArray();
		for(String s:list){
			json.add(url+s);
		}
		
		response.setContentType("application/json; charset=utf-8");
		response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		out.write(json.toString());
		System.out.println("返回的json数据：" + json.toString());
	}

}
